/*
#Copyright (c) 2013, Philippe Bordron <philippe.bordron@gmail.com>
#
# This file is part of SIPPER.
#
# DCC is free software: you can redistribute it and/or modify
# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DCC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU LESSER GENERAL PUBLIC LICENSE for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# along with SIPPER.  If not, see <http://www.gnu.org/licenses/>
*/
package combi.wip.graph.algo.ksp;

import combi.graph.Mask;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Set;

import combi.wip.graph.algo.ksp.threads.ThreadPourControleChemins;

import org.jgrapht.graph.DefaultDirectedWeightedGraph;
import org.jgrapht.graph.DefaultWeightedEdge;

public class ControleCheminsEnParallele extends ThreadPourControleChemins{

	
	private Collection<Set<Integer>> debElem;
	private Collection<Set<Integer>> finElem;
	LabelGroupeSommets<Set<Integer>> labels;
	DefaultDirectedWeightedGraph<Integer, DefaultWeightedEdge> graph;
	int fakeSrc;
	int fakeDest;
	int k;
	String outFile;
	Mask<Integer, DefaultWeightedEdge> maskBase;
	
	public ControleCheminsEnParallele(int nb_threads,
			DefaultDirectedWeightedGraph<Integer, DefaultWeightedEdge> graph,
			int fakeSrc,
			int fakeDest, 
			Mask<Integer, DefaultWeightedEdge> maskBase,
			int k,
			Collection<Set<Integer>> debElem ,
			Collection<Set<Integer>> finElem, 
			LabelGroupeSommets<Set<Integer>> labels,
			String outFile)
	{
		super(nb_threads);
		this.fakeSrc = fakeSrc;
		this.fakeDest = fakeDest;
		this.debElem = debElem;
		this.finElem = finElem;
		this.labels = labels;
		this.outFile = outFile;
		this.graph = graph;
		this.maskBase = maskBase;
		this.k = k;
	}
	
	
	public void run()
	{
		synchronized(this)
		{
			int progression = 0;
			int total =debElem.size();
			for (Set<Integer> entry1 : debElem)
			{
				String debut = entry1.toString();
				if (labels != null)
				{
					 debut = labels.getLabel(entry1);
				}
				System.out.println(debut + " : " + progression*100/total + "% - " + new Date(java.lang.System.currentTimeMillis()));
				Thread t = new TraiteDebutChemins(this, nb_threads,graph, maskBase, fakeSrc,fakeDest, k, entry1, finElem, debut, labels, outFile);
				super.add();
				t.start();
				progression++;
			}
		}
	}
	
}
